package com.cloud.servicezuul.controller;

import com.cloud.servicezuul.properties.GoodManProperty;
import com.cloud.servicezuul.service.TestSentinelService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/myController")
public class MyController {

    @Autowired
    private GoodManProperty goodManProperty;

    @Autowired
    private TestSentinelService testSentinelService;


    @GetMapping("/getLocalMessage")
    public String forwardMsg(){
        return "myController,address:" + goodManProperty.getAddress();
    }

    /**
     * 测试 Sentinel 的 注解模式
     * @return 测试结果
     */
    @GetMapping("/testSentinelAnn")
    public String testSentinelAnn(){
       return testSentinelService.testSentinelAnn();
    }

    /**
     * 测试 Sentinel 的 注解模式 使用限流处理类
     * @return 测试结果
     */
    @GetMapping("/testSentinelAnnBlockHandle")
    public String testSentinelAnnBlockHandle(){
        return testSentinelService.testSentinelBlockHandleClass();
    }
}
